package com.example.administrator.pachong;

import org.greenrobot.greendao.annotation.Unique;

import java.util.List;

/**
 * Created by Administrator on 2017/3/31 0031.
 */

public class LoveDao {

        /**
         * 添加数据，如果有重复则覆盖
         *
         * @param user
         */
        public static void insertLove(User user) {
            BaseApplication.getDaoInstant().getUserDao().insertOrReplace(user);
        }

        /**
         * 删除数据
         *
         * @param id
         */
        public static void deleteLove(long id) {
            BaseApplication.getDaoInstant().getUserDao().deleteByKey(id);
        }

        /**
         * 更新数据
         *
         * @param user
         */
        public static void updateLove(User user) {
            BaseApplication.getDaoInstant().getUserDao().update(user);
        }

        /**
         * 查询条件为Type=TYPE_LOVE的数据
         *
         * @return
         */
        public static List<User> queryLove() {
            return BaseApplication.getDaoInstant().getUserDao().queryBuilder().where(UserDao.Properties.Age.eq(User.TYPE_LOVE)).list();
        }

        /**
         * 查询全部数据
         */
        public static List<User> queryAll() {
            return BaseApplication.getDaoInstant().getUserDao().loadAll();
        }

    }
